package org.itsky.consulconsumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author sky
 * @Site cmtianxie163.com 2020/4/4 20:57
 */
@RestController
public class UseHelloController {
    @Autowired
    LoadBalancerClient loadBalancerClient;

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/hello1")
    public void hello1(){
        ServiceInstance choose = loadBalancerClient.choose("consul-provider");
        System.out.println("服务器地址是 "+ choose.getUri());

    }



}
